package com.smalls.newvideotwo.utils;

import android.content.Context;
import android.content.SharedPreferences;
import com.smalls.newvideotwo.NewDTVApp;
import com.smalls.newvideotwo.util.LogUtil;

public class PreferenceUtil {
	private static final String PREF_NAME = "AAA_DEFAULT_SERVER";
	public static final String KEY_BASE_URL = "base_url";

	public static SharedPreferences getSp(Context ctx) {
		return ctx.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
	}

	public static String getBaseUrl(Context ctx) {
		return getSp(ctx).getString(KEY_BASE_URL, "");
	}

	public static void setBaseUrl(Context ctx, String str) {
		LogUtil.e("PreferenceUtil", "setBaseUrl-str=" + str);
		getSp(ctx).edit().putString(KEY_BASE_URL, str).commit();
	}
	
	
	public static boolean getOrderSet(){
        return NewDTVApp.getApp().sharedPre.getBoolean("sort", false);
    }

    public static void setOrderSet(boolean b) {
        NewDTVApp.getApp().editor.putBoolean("sort", b);
        NewDTVApp.getApp().editor.commit();
    }

    public static void setIp(String ipString) {
        NewDTVApp.getApp().editor.putString("ip", ipString);
        NewDTVApp.getApp().editor.commit();
    }

    public static String getIp() {
        return NewDTVApp.getApp().sharedPre.getString("ip", "127.0.0.1");
    }
}
